<?php 
namespace app\common\model;

use think\Model;

class CompanyStaff extends Model
{
	protected function setBirthAttr($v)
	{
		return $v ? strtotime($v) : $v;
	}
	protected function getBirthAttr($v)
	{
		return $v ? date('Y-m-d',$v) : '-';
	}
	
	protected function getDepartNameAttr($v,$data)
	{
		$depar_id = CompanyStaffDepart::where(['staff_id' => $data['id']])->value('depart_id');
		return CompanyDepartment::get($depar_id)->depart_name;
	}
	
	protected function getPostNameAttr($v,$data)
	{
		$post_id = CompanyStaffDepart::where(['staff_id' => $data['id']])->value('post_id');
		return CompanyJobpost::get($post_id)->post_name;
	}
}